/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Modelo;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author ChArFaTo
 */
@Entity
@Table(name = "grupo", catalog = "proyectosw", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "GrupoEJB.findAll", query = "SELECT g FROM GrupoEJB g"),
    @NamedQuery(name = "GrupoEJB.findByGCodigo", query = "SELECT g FROM GrupoEJB g WHERE g.gCodigo = :gCodigo"),
    @NamedQuery(name = "GrupoEJB.findByGNombre", query = "SELECT g FROM GrupoEJB g WHERE g.gNombre = :gNombre"),
    @NamedQuery(name = "GrupoEJB.findByGNumeroestudiantesminimo", query = "SELECT g FROM GrupoEJB g WHERE g.gNumeroestudiantesminimo = :gNumeroestudiantesminimo"),
    @NamedQuery(name = "GrupoEJB.findByGNumeroestudiantesmaximo", query = "SELECT g FROM GrupoEJB g WHERE g.gNumeroestudiantesmaximo = :gNumeroestudiantesmaximo")})
public class GrupoEJB implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(nullable = false)
    private Integer gCodigo;
    @Size(max = 255)
    @Column(length = 255)
    private String gNombre;
    @Basic(optional = false)
    @NotNull
    @Column(nullable = false)
    private int gNumeroestudiantesminimo;
    @Basic(optional = false)
    @NotNull
    @Column(nullable = false)
    private int gNumeroestudiantesmaximo;
    @ManyToMany(mappedBy = "grupoEJBCollection")
    private Collection<MatriculaacademicaEJB> matriculaacademicaEJBCollection;
    @JoinTable(name = "estudiante_grupo", joinColumns = {
        @JoinColumn(name = "GrupoGCodigo", referencedColumnName = "GCodigo", nullable = false)}, inverseJoinColumns = {
        @JoinColumn(name = "EstudianteECodigo", referencedColumnName = "ECodigo", nullable = false)})
    @ManyToMany
    private Collection<EstudianteEJB> estudianteEJBCollection;
    @JoinColumn(name = "AsignaturaAcodigo", referencedColumnName = "Acodigo")
    @ManyToOne
    private AsignaturaEJB asignaturaAcodigo;
    @JoinColumn(name = "DocenteDTarjetaProfesional", referencedColumnName = "DTarjetaProfesional")
    @ManyToOne
    private DocenteEJB docenteDTarjetaProfesional;
    @OneToMany(mappedBy = "grupoGCodigo")
    private Collection<HorarioEJB> horarioEJBCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "grupoEJB")
    private Collection<HistorialnotaEJB> historialnotaEJBCollection;
    @OneToMany(mappedBy = "grupoGCodigo")
    private Collection<SalonEJB> salonEJBCollection;

    public GrupoEJB() {
    }

    public GrupoEJB(Integer gCodigo) {
        this.gCodigo = gCodigo;
    }

    public GrupoEJB(Integer gCodigo, int gNumeroestudiantesminimo, int gNumeroestudiantesmaximo) {
        this.gCodigo = gCodigo;
        this.gNumeroestudiantesminimo = gNumeroestudiantesminimo;
        this.gNumeroestudiantesmaximo = gNumeroestudiantesmaximo;
    }

    public Integer getGCodigo() {
        return gCodigo;
    }

    public void setGCodigo(Integer gCodigo) {
        this.gCodigo = gCodigo;
    }

    public String getGNombre() {
        return gNombre;
    }

    public void setGNombre(String gNombre) {
        this.gNombre = gNombre;
    }

    public int getGNumeroestudiantesminimo() {
        return gNumeroestudiantesminimo;
    }

    public void setGNumeroestudiantesminimo(int gNumeroestudiantesminimo) {
        this.gNumeroestudiantesminimo = gNumeroestudiantesminimo;
    }

    public int getGNumeroestudiantesmaximo() {
        return gNumeroestudiantesmaximo;
    }

    public void setGNumeroestudiantesmaximo(int gNumeroestudiantesmaximo) {
        this.gNumeroestudiantesmaximo = gNumeroestudiantesmaximo;
    }

    @XmlTransient
    public Collection<MatriculaacademicaEJB> getMatriculaacademicaEJBCollection() {
        return matriculaacademicaEJBCollection;
    }

    public void setMatriculaacademicaEJBCollection(Collection<MatriculaacademicaEJB> matriculaacademicaEJBCollection) {
        this.matriculaacademicaEJBCollection = matriculaacademicaEJBCollection;
    }

    @XmlTransient
    public Collection<EstudianteEJB> getEstudianteEJBCollection() {
        return estudianteEJBCollection;
    }

    public void setEstudianteEJBCollection(Collection<EstudianteEJB> estudianteEJBCollection) {
        this.estudianteEJBCollection = estudianteEJBCollection;
    }

    public AsignaturaEJB getAsignaturaAcodigo() {
        return asignaturaAcodigo;
    }

    public void setAsignaturaAcodigo(AsignaturaEJB asignaturaAcodigo) {
        this.asignaturaAcodigo = asignaturaAcodigo;
    }

    public DocenteEJB getDocenteDTarjetaProfesional() {
        return docenteDTarjetaProfesional;
    }

    public void setDocenteDTarjetaProfesional(DocenteEJB docenteDTarjetaProfesional) {
        this.docenteDTarjetaProfesional = docenteDTarjetaProfesional;
    }

    @XmlTransient
    public Collection<HorarioEJB> getHorarioEJBCollection() {
        return horarioEJBCollection;
    }

    public void setHorarioEJBCollection(Collection<HorarioEJB> horarioEJBCollection) {
        this.horarioEJBCollection = horarioEJBCollection;
    }

    @XmlTransient
    public Collection<HistorialnotaEJB> getHistorialnotaEJBCollection() {
        return historialnotaEJBCollection;
    }

    public void setHistorialnotaEJBCollection(Collection<HistorialnotaEJB> historialnotaEJBCollection) {
        this.historialnotaEJBCollection = historialnotaEJBCollection;
    }

    @XmlTransient
    public Collection<SalonEJB> getSalonEJBCollection() {
        return salonEJBCollection;
    }

    public void setSalonEJBCollection(Collection<SalonEJB> salonEJBCollection) {
        this.salonEJBCollection = salonEJBCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (gCodigo != null ? gCodigo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof GrupoEJB)) {
            return false;
        }
        GrupoEJB other = (GrupoEJB) object;
        if ((this.gCodigo == null && other.gCodigo != null) || (this.gCodigo != null && !this.gCodigo.equals(other.gCodigo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Modelo.GrupoEJB[ gCodigo=" + gCodigo + " ]";
    }
    
}
